<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
<script type="text/html" id="files-item-tpl">
    <li id="saved-file{id}">
        <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
        <input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
               style="width: 200px;" title="文件名称">
        <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
        <a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
        <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
    </li>
</script>

</head>
<body>

<h1>-批量导入任务-</h1>

<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('AdminIndex/index')}">任务列表</a></li>
        <li><a href="{:url('AdminIndex/add')}">发布任务</a></li>
        <li class="active"><a href="{:url('AdminIndex/add2')}">批量任务</a></li>
    </ul>
    <form action="{:url('AdminIndex/add2Post')}" method="post" class="form-horizontal js-ajax-form margin-top-20" onsubmit="return validate_form(this)">
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered">

                    <tr>
                        <th>任务标题<span class="form-required">*</span></th>
                        <td id="title_td" class="must_choose" onclick="setBackground()">
                            <input class="form-control" type="text" name="title"
                                   id="title" required value="" placeholder="请输入任务标题"/>
                        </td>
                    </tr>
                    <tr>
                        <th>任务内容<span class="form-required">*</span></th>
                        <td>

                            <textarea placeholder="请输入任务内容" name="task_content" type="text" style="width:770px; height:100px"></textarea>
                            <input type="button" value="图" style="width: 30px; height: 30px; border-radius: 50%;border: none">
                        </td>
                    </tr>
                    <tr>
                        <th>抄送<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" type="text" name="t_cc"
                                   value="" placeholder="请输入抄送电话"/>
                        </td>
                    </tr>

                    <tr>
                        <th>
                            <label>任务种类<span class="form-required">*</span></label>
                        </th>
                        <td>

                                <select name="type">
                                    <option value="0">通知</option>
                                    <option value="1">市场</option>
                                    <option value="2">网运</option>
                                    <option value="3">人事</option>
                                </select>

                        </td>
                    </tr>

                    <tr>
                        <th>
                            <label>任务标签<span class="form-required">*</span></label>
                        </th>
                        <td>

                                <select name="tag">
                                    <option value="0">通知类无需回复附件</option>
                                    <option value="1">必须处理人回复</option>
                                    <option value="2">必须处理人回复和图片</option>
                                </select>

                        </td>
                    </tr>

                    <tr>
                        <th>
                            <label>截止日期<span class="form-required">*</span></label>
                        </th>
                        <td>
                            <input type="text" class="form-control js-bootstrap-datetime" name="deadline"
                                   value="{$start_time|default=''}"
                                   style="width: 160px;" required autocomplete="off">

                        </td>
                    </tr>

                    <tr>
                        <th>
                            <label>导入任务附件<br>(必选)<span class="form-required">*</span></label>
                        </th>

                        <td class="form-inline" id="files_td" onclick="setBackground()">
                            <input id="file-video" class="form-control" type="text" name="appendix"
                                   value="" placeholder="请上传EXCEL文件" style="width: 200px;" readonly="readonly"
                                    onclick="uploadOne('文件上传','#file-video','file')">

                            <a href="javascript:uploadOne('文件上传','#file-video','file');">上传</a>
                        </td>

                    </tr>

                </table>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">导入任务</button>
                        <a class="btn btn-default" href="{:url('AdminIndex/index')}">{:lang('BACK')}</a>
                    </div>
                </div>
            </div>

        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });

    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('AdminCategory/select')}?ids=" + selectedCategoriesId, '请选择分类', {
            area: ['700px', '400px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择分类');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
    function setBackground() {
        $("td.must_choose").attr("style","background-color: #ffffff");
        $("td.form-inline").attr("style","background-color: #ffffff");
    }
    function validate_form(thisform)
    {

        if (thisform.title.value==null||thisform.title.value==''){
            $("td#title_td").attr("style","background-color: #ffe5e5 ");
            return false
        }
        if (thisform.deadline.value==null||thisform.deadline.value==''){
            $("td#deadline_td").attr("style","background-color: #ffe5e5 ");
            return false
        }
        var file = $("input#file-video").val()

        if (!file) {
            $("td#files_td").attr("style","background-color: #ffe5e5 ");
            return false
        }
        return true

    }
</script>
</body>
</html>
